package org.fintool.common;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;


//1 is Sunday, 2 is Monday,3-tuesday,4-wednesday,5=thursday,6=friday and 7 is Saturday
//1 and 7 need to be excluded
public class DateTimeUtil {
	
	public final static int getDayOfWeek(final long timeinMillis){
		
		int retDayofWeek=0;
		try{
			Date date=new Date(timeinMillis);
			if(date!=null){
				retDayofWeek=getDayOfWeek(date);
				
			}
		
		}catch (Exception e) {
			// TODO: handle exception
		}
		
		return  retDayofWeek;
	}
	
	public final static int getDayOfWeek(final Date dateTime){
		int retDayofWeek=0;
		
		try{
			Calendar calenderDate = new GregorianCalendar();
			calenderDate.setTime(new Date());
			
			if(calenderDate.getTime()!=null){
				retDayofWeek=calenderDate.get(Calendar.DAY_OF_WEEK);
				
			}
			
		}catch (Exception e) {
			// TODO: handle exception
		}
		
		
		return retDayofWeek;
	}
	
	
	public static void main(String[] args) {
		
		
		Calendar calenderDate = new GregorianCalendar();
		calenderDate.setTime(new Date());
		
		//1 is Sunday, 2 is Monday,3-tuesday,4-wednesday,5=thursday,6=friday and 7 is Saturday
		System.out.println(calenderDate.get(Calendar.DAY_OF_WEEK));    // 6=Friday

		
	}

}
